#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#define f(x, y, z) for(int x = (y); x <= (z); ++x)
#define g(x, y, z) for(int x = (y); x < (z); ++x)
#define h(x, y, z) for(int x = (y); x >= (z); --x)
#define foreach(x, y) for(__typeof(y.begin()) x = y.begin(); x != y.end(); ++x)

std::vector<char> chars[3];
#define cl (chars[0])
#define pt (chars[1])
#define cy (chars[2])
void R(std::vector<char> &v){
	putchar(v[rand() % v.size()]);
}

int jiajian, chengchu, putong, chengyuan, kuohao;

bool av(int type){
	if(type == 2 && !kuohao) return false;
	if(type == 3 && !putong) return false;
	if(type == 4 && !chengyuan) return false;
	if(type == 5 && !chengchu) return false;
	if(type == 6 && !jiajian) return false;
	return true;
}

void gen(int type, int len){
	// printf("gen %d %d\n", type, len);
	if(type == 1) R(cl);
	else if(type == 2){
		if(len <= 3){
			gen(1, len); return;
		}
		putchar('(');
		gen(7, len - 2);
		putchar(')');
	}else if(type == 3){
		if(len <= 4){
			gen(1, len); return;
		}
		std::map<int, int> si;
		int xl = len - 2;
		while(xl){
			int i = 0;
			while((rand() % 2) && (rand() % 2) && (rand() % 2)) ++i;
			if(si[i]){
				++si[i]; --xl;
			}else if(xl >= 2){
				++si[i]; xl -= 2;
			}
		}
		std::vector<int> vi;
		foreach(it, si) if(it->second) vi.push_back(it->second);
		std::random_shuffle(vi.begin(), vi.end());
		R(pt);
		putchar('(');
		bool first = true;
		foreach(it, vi){
			if(first) first = false; else putchar(',');
			gen(7, *it);
		}
		putchar(')');
	}else if(type == 4){
		if(len <= 6){
			gen(1, len); return;
		}
		start4:;
		std::map<int, int> si;
		int xl = len - 2;
		while(xl){
			int i = 0;
			while((rand() % 2) && (rand() % 2) && (rand() % 2)) ++i;
			if(si[i]){
				++si[i]; --xl;
			}else if(xl >= 2){
				++si[i]; xl -= 2;
			}
		}
		std::vector<int> vi;
		foreach(it, si) if(it->second) vi.push_back(it->second);
		std::random_shuffle(vi.begin(), vi.end());
		if(vi.size() < 2) goto start4;
		int il = vi.back(); vi.pop_back();
		int nty = 4;
		for(;;){
			while(rand() % 2) if(!--nty) nty = 4;
			if(av(nty)) break; else nty = 4;
		}
		gen(nty, il);
		putchar('.');
		R(cy);
		putchar('(');
		bool first = true;
		foreach(it, vi){
			if(first) first = false; else putchar(',');
			gen(7, *it);
		}
		putchar(')');
	}else if(type == 5){
		std::map<int, int> si;
		int xl = len + 1;
		while(xl){
			int i = 0;
			while((rand() % 2) && (rand() % 2) && (rand() % 2)) ++i;
			if(si[i]){
				++si[i]; --xl;
			}else if(xl >= 2){
				++si[i]; xl -= 2;
			}
		}
		std::vector<int> vi;
		foreach(it, si) if(it->second) vi.push_back(it->second);
		bool first = true;
		foreach(it, vi){
			if(first) first = false; else putchar("*/"[rand() % 2]);
			int nty = 4;
			for(;;){
				while(rand() % 2) if(!--nty) nty = 4;
				if(av(nty)) break; else nty = 4;
			}
			gen(nty, *it);
		}
	}else if(type == 6){
		std::map<int, int> si;
		int xl = len + 1;
		while(xl){
			int i = 0;
			while((rand() % 2) && (rand() % 2) && (rand() % 2)) ++i;
			if(si[i]){
				++si[i]; --xl;
			}else if(xl >= 2){
				++si[i]; xl -= 2;
			}
		}
		std::vector<int> vi;
		foreach(it, si) if(it->second) vi.push_back(it->second);
		bool first = true;
		foreach(it, vi){
			if(first) first = false; else putchar("+-"[rand() % 2]);
			int nty = 5;
			for(;;){
				while(rand() % 2) if(!--nty) nty = 5;
				if(av(nty)) break; else nty = 5;
			}
			gen(nty, *it);
		}
	}else{
		int nty = 6;
		for(;;){
			while(rand() % 2) if(!--nty) nty = 6;
			if(av(nty)) break; else nty = 6;
		}
		gen(nty, len);
	}
}

int main(int argc, char **argv){
	sscanf(argv[1], "%d", &jiajian);
	sscanf(argv[2], "%d", &chengchu);
	sscanf(argv[3], "%d", &putong);
	sscanf(argv[4], "%d", &chengyuan);
	sscanf(argv[5], "%d", &kuohao);
	int ty, len;
	sscanf(argv[6], "%d", &len);
	sscanf(argv[7], "%d", &ty);
	srand(jiajian + chengchu * 2 + putong * 4 + chengyuan * 8 + kuohao * 16 + len * 32);
	f(i, 'a', 'z') chars[rand() % 3].push_back(i);
	gen(ty, len);
	return 0;
}
